package lesson02;

import lesson02.UDP.UDPDictServer01;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UDPDictServer02 extends UDPDictServer01 {
    private Map<String,String> map;

    public UDPDictServer02(int port) throws SocketException {
        super(port);
        map = new HashMap<>();
        map.put("tiger","老虎");
        map.put("dig","狗");
        map.put("cat","猫");
        map.put("pig","猪");
    }


    protected String process(String key){
        key = map.getOrDefault(key,"查无此人");
        return key;
    }

    public static void main(String[] args) throws IOException {
        UDPDictServer02 server = new UDPDictServer02(9999);
        server.start();

    }
}
